export default class extends think.Logic {
  async indexAction(){
    let rules = {
      //分页
      page: {
        int: true,  
        default: 1
      },
      //点赞
      praise:{
        int: true,
        in: [0,1]
      },
      //收藏
      collect:{
        int: true,
        in: [0,1]
      },
      //评论
      comment:{
        int: true,
        in: [0,1]
      },
      //每页的条数
      num:{
        int: true,
        default: 10 
      },
      //选择的用户
      uids:{
        string:true  
      },
      //选择的栏目
      cids:{
        string:true 
      }
    }
    // 自定义错误信息
    let msgs = {
      page: {
        int: '必须是整数', 
      },
      praise: {
        required : '必须是整数',
        in : '值必须是0(升序)或1(降序)'
      },
      collect: {
        required : '必须是整数',
        in : '值必须是0(升序)或1(降序)'
      },
      comment: {
        required : '必须是整数',
        in : '值必须是0(升序)或1(降序)'
      },
      num: {
        int:'必须是整数'
      },
      uids: {
        string:'必须是字符串'
      },
      cids: {
        string:'必须是字符串'
      }
    }
    let flag = this.validate(rules,msgs);
    if(!flag){
      return this.fail(1000,'validate error', this.validateErrors);
    }
  }
}
